import * as echarts from 'echarts'
import { onUnmounted } from 'vue'

const useEcharts = (ele: any) => {
  const echartsIns = echarts.init(ele, 'light', { renderer: 'svg' })
  const setOption = (opt: any) => {
    echartsIns.setOption(opt)
  }
  onUnmounted(() => {
    //   组件卸载时销毁echarts实例
    echartsIns.dispose()
  })
  return { setOption }
}

export default useEcharts
